package com.nahan.secondapplication.evaluation;

import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.nahan.secondapplication.R;
import com.nahan.secondapplication.evaluation.ThreeLevelRating.ThreeLevelRatingBarView;

import java.text.DecimalFormat;

/**
 * @describe: 描述：
 * @time: 2020-9-3 10:35:49
 */
public class EvaluationActivity extends AppCompatActivity {

    private ThreeLevelRatingBarView ratingTotal;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_evaluation);

        ratingTotal=findViewById(R.id.ratingTotal);
        //代码操作与系统控件操作方法一致
        ratingTotal.setRating(2);//代码设置星级
//        rating= String.valueOf(ratingTotal.getRating());//获取当前星级
        ratingTotal.setClickable(true);//默认可点击不用设置，false为不可点击


        //点击设置星级
        ratingTotal.setOnRatingBarChangeListener(new ThreeLevelRatingBarView.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(float RatingScore) {
                DecimalFormat decimalFormat=new DecimalFormat("0.0");
                Toast.makeText(EvaluationActivity.this, decimalFormat.format(RatingScore)+"",Toast.LENGTH_SHORT).show();
            }
        });
    }
}
